<?php
class Tool_benchmark{

  public static function bench_function($function, &$arg, $nb_xp, $timer){
    for($i=0;$i<$nb_xp;++$i){
      $timer->go();
      call_user_func($function, $arg);
      $timer->stop();
    }
  }

  public function bench_array_functions($array_functions, &$arg, $nb_xp, $timer){
    foreach($array_functions as $function){
      Tool_benchmark::bench_function($function,$arg,$nb_xp,$timer);
      $timer->new_lap();
    }
  }

  public function print_info_bench($array_names, $timer){
    $avg = $timer->get_average_each();
    $sum = $timer->get_sum_lap();
    foreach($array_names as $i=>$name){
      print sprintf('%s :: average = %.3f, total = %.3f', $name, $avg[$i], $sum[$i]);
      print "\n";
    }
  }

}

?>
